package com.monkey.algorithm.chapter1.accumulator

/**
 * 作者：Monkey
 * 日期：2018/1/24
 */
open class Accumulator {
    var total: Double = 0.0
        private set

    var count: Int = 0
        private set

    open fun addDataValue(value: Double) {
        count++
        total += value
    }

    fun mean() = total / count

    override fun toString(): String {
        return "Accumulator(total=$total, count=$count)"
    }
}